// OrderStatus.java
package com.health.common.enums;

import java.util.Arrays;
import java.util.List;

/**
 * 订单状态枚举
 */
public enum OrderStatus {
    PENDING_PAYMENT("0", "待付款"),
    PENDING_SHIPMENT("1", "待发货"),
    PENDING_RECEIPT("2", "待收货"),
    COMPLETED("3", "已完成"),
    CANCELLED("4", "已取消"),
    AFTER_SALES("5", "售后中");

    private final String code;
    private final String desc;

    OrderStatus(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static OrderStatus getByCode(String code) {
        for (OrderStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }

    public static String getDescByCode(String code) {
        OrderStatus status = getByCode(code);
        return status != null ? status.getDesc() : "未知状态";
    }
    /**
     * 获取所有统计类型
     */
    public static List<OrderStatus> getAllTypes() {
        return Arrays.asList(values());
    }
}